export default {
    state: {
        visitedPath: [{
            path: "/home",
            meta: { title: "首页", icon: "dashboard", noCache: true, affix: true, all: true },
            name: "Home"
        }]
        // visitedPath: []
    },
    mutations: {
        visitedPathAdd(state, v) {
            // debugger
            // if(state.visitedPath.indexOf(v) <0){
            //     return state.visitedPath.push(v)
            // }
            if (state.visitedPath.length == 0) {
                return state.visitedPath.push(v)
            } else {
                let i = 0
                state.visitedPath.forEach(item => {
                    // debugger
                    if (item.path != v.path) {
                        i++;
                        if (i == state.visitedPath.length) {
                            return state.visitedPath.push(v)
                        }
                    }
                });
            }


        },
        visitedPathReset(state, v) {
            return state.visitedPath = [{
                path: "/home",
                meta: { title: "首页", icon: "dashboard", noCache: true, affix: true, all: true },
                name: "Home"
            }]
        },
        visitedRightSetR(state, v) {

            return state.visitedPath.splice(v, 999999999)

        },
        visitedRightSetL(state, v) {

            return state.visitedPath.splice(1, v)


        }

    }
}